<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>计划管理</title>

<script src="../../plugs/jquery-3.1.1.min.js"></script>
<link rel="stylesheet"
	href="../../assets/bootstrap/css/bootstrap.min.css">
<script
	src="../../assets/bootstrap/js/bootstrap.min.js"></script>
<!--富文本编辑器-->
	<link href="../../assets/summernote/summernote.css" rel="stylesheet">
	<script src="../../assets/summernote/summernote.js"></script>
<!--jquery-ui-->
<link href="https://cdn.bootcss.com/jqueryui/1.12.1/jquery-ui.css"
	rel="stylesheet">
<script src="https://cdn.bootcss.com/jqueryui/1.12.1/jquery-ui.js"></script>
<script src="../js/uploadPreview.js" type="text/javascript"></script>
<script src="https://cdn.bootcss.com/jquery.form/4.2.1/jquery.form.js"></script>
<link rel="stylesheet" href="../css/platformManager.css">
	<link rel="stylesheet" href="../../css/layer/mobile/need/layer.css">
	<script type="text/javascript" src="../../css/layer/layer.js"></script>

</head>
<body>
	<div class="container" style="margin-top:20px;width: 1670px">
		<form class="form-horizontal" id="businessForm" method="post" enctype="multipart/form-data">
			<fieldset>

				<!-- Form Name -->
				<legend>企业信息</legend>
				<div class="control-group" style="display:none">
					<div class="controls">
						<label class="control-label" for="businessName">企业Id</label>
						 <input id="businessId" name="businessId" placeholder="企业Id"
							class="input-xlarge" type="text" required="required">
					</div>
				</div>

				<!-- Text input-->
				<div class="control-group">
					<div class="controls">
						<label class="control-label" for="businessName">企业名称</label> <input
							id="businessName" name="businessName" placeholder="企业名称"
							class="input-xlarge" type="text" disabled="disabled" required="required">

					</div>
				</div>

				<!-- Text input-->
				<div class="control-group">
					<div class="controls">
						<label class="control-label" for="businessAddr">企业地址</label> <input
							id="businessAddr" name="businessAddr" placeholder="企业地址"
							class="input-xlarge" type="text" required="required">
					</div>
				</div>

				<!-- Text input-->
				<div class="control-group">
					<div class="controls">
						<label class="control-label" for="businessUrl">企业官网</label> <input
							id="businessUrl" name="businessUrl" placeholder="企业官网"
							class="input-xlarge" type="text" required="required">
					</div>
				</div>

				<!-- Text input-->
				<div class="control-group">
					<div class="controls">
						<label class="control-label" for="businessEmail">企业邮箱</label> <input
							id="businessEmail" name="businessEmail" placeholder="企业邮箱"
							class="input-xlarge" type="text" required="required">
					</div>
				</div>

				<!-- Text input-->
				<div class="control-group">
					<div class="controls">
						<label class="control-label" for="businessMobile">联系电话</label> <input
							id="businessMobile" name="businessMobile" placeholder="联系电话"
							class="input-xlarge" type="text" required="required">
					</div>
				</div>
				
				<div class="control-group">
					<div class="controls">
						<label class="control-label" for="businessLog">企业图标</label> <input
							id="logo" name="logo" class="input-xlarge"
							type="file">
					</div>
				</div>
				<div class="control-group">
					<div id="divShow" class="controls" style="padding-left:120px;">
						<img id="logoShow" src="../../assets/logo.png" alt="logoShow"  style="max-width:120px;"/>
					</div>
				</div>
				
				<!-- Textarea -->
				
				<div class="control-group">
					<div class="controls">
						<label class="control-label" for="businessDesc">企业简介</label> <textarea
							id="businessDesc" name="businessDesc" placeholder="企业简介"
							class="input-xlarge" required="required"
							rows="5" cols="30"></textarea>
					</div>
				</div>
				
				

				<div class="control-group">
                	<button type="button" id="submit" name="submit" class="btn btn-info" style="margin-top:90px;">提交</button>
          	  	</div>

			</fieldset>
		</form>
</div>
<script>
			window.onload = function () 
			{ 
				new uploadPreview({ UpBtn: "logo", DivShow: "divShow", ImgShow: "logoShow" });
			}
</script>
<script>
$(function()
{	
    	var businessId = $(window.parent.parent.frames["topFrame"].document).find('#businessId').text();
    	$.ajax({
        	url:"../getBusinessInfo.do",
       		type:"post",
        	data:{
            	"businessId":businessId
        	},
       		success:function(data){
       			fillForm(data);
       		},
       		error:function(status)
       		{
       			
       		}
    	});
    	
    	function fillForm(data)
    	{
    		var logosrc= data.businessInfo.businessLogo;
    		var businessName = data.businessInfo.businessName;
    		var businessAddr = data.businessInfo.businessAddr;
    		var businessUrl = data.businessInfo.businessUrl;
    		var businessEmail = data.businessInfo.businessEmail;
    		var businessMobile = data.businessInfo.businessMobile;
    		var businessDesc =  data.businessInfo.businessDesc;
    		//var comment = data.businessInfo.businessDesc;
    		$("#businessId").val(businessId);
    		$("#businessName").val(businessName);
    		$("#businessAddr").val(businessAddr);
    		$("#businessUrl").val(businessUrl);
    		$("#businessEmail").val(businessEmail);
    		$("#businessMobile").val(businessMobile);
    		$("#businessDesc").val(businessDesc);
    		//$("#comment").text(comment);
    		$("#logoShow").attr("src","../../"+logosrc);
    	};   
    	
    	
    	$('#submit').click(function(){	
    		 var name = $("#logo").val();
    		// console.log($("#imgFile")[0].files[0].size);//小于100*1024，下面的请求就可以成功
    		 var option = {
    		  url : '../updateBusinessInfo.do',
    		  type : 'post',
    		//  dataType : 'json',
    		  headers : {"ClientCallMode" : "ajax"}, //添加请求头部
    		  success : function(XMLHttpRequest, textStatus, errorThrown){
				  layer.msg("前端输出上传成功",{icon: 1})
    		 //  $("#imgClose").click();
    		  },
    		  error: function(XMLHttpRequest, textStatus, errorThrown) {
				  layer.msg("前端输出上传失败",{icon: 5})
    		  }
    		 };
    		
    		 $("#businessForm").ajaxSubmit(option);
    		 	return false;  		
    	});	
});		
</script>
</body>
</html>